#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <unordered_map>
// 反转链表：https://leetcode.cn/problems/reverse-linked-list/description/
using namespace std;
class Solution {
public:
    ListNode* dfs(ListNode* head)
    {
        if(head==nullptr||head->next==nullptr)
        {
            return head;
        }
        ListNode* cur=dfs(head->next);
        head->next->next=head;
        head->next=nullptr;
        return cur;
    }
    ListNode* reverseList(ListNode* head) {
        return dfs(head);
    }
};